package com.fss.shopman.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.fss.common.annotation.Log;
import com.fss.common.core.controller.BaseController;
import com.fss.common.core.domain.AjaxResult;
import com.fss.common.enums.BusinessType;
import com.fss.shopman.domain.Shopman;
import com.fss.shopman.service.IShopmanService;
import com.fss.common.utils.poi.ExcelUtil;
import com.fss.common.core.page.TableDataInfo;

/**
 * 店铺信息Controller
 * 
 * @author ruoyi
 * @date 2024-12-02
 */
@RestController
@RequestMapping("/shopman/shopman")
public class ShopmanController extends BaseController
{
    @Autowired
    private IShopmanService shopmanService;

    /**
     * 查询店铺信息列表
     */
    @PreAuthorize("@ss.hasPermi('shopman:shopman:list')")
    @GetMapping("/list")
    public TableDataInfo list(Shopman shopman)
    {
        startPage();
        List<Shopman> list = shopmanService.selectShopmanList(shopman);
        return getDataTable(list);
    }

    /**
     * 导出店铺信息列表
     */
    @PreAuthorize("@ss.hasPermi('shopman:shopman:export')")
    @Log(title = "店铺信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Shopman shopman)
    {
        List<Shopman> list = shopmanService.selectShopmanList(shopman);
        ExcelUtil<Shopman> util = new ExcelUtil<Shopman>(Shopman.class);
        util.exportExcel(response, list, "店铺信息数据");
    }

    /**
     * 获取店铺信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('shopman:shopman:query')")
    @GetMapping(value = "/{shopId}")
    public AjaxResult getInfo(@PathVariable("shopId") Long shopId)
    {
        return success(shopmanService.selectShopmanByShopId(shopId));
    }

    /**
     * 新增店铺信息
     */
    @PreAuthorize("@ss.hasPermi('shopman:shopman:add')")
    @Log(title = "店铺信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Shopman shopman)
    {
        return toAjax(shopmanService.insertShopman(shopman));
    }

    /**
     * 修改店铺信息
     */
    @PreAuthorize("@ss.hasPermi('shopman:shopman:edit')")
    @Log(title = "店铺信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Shopman shopman)
    {
        return toAjax(shopmanService.updateShopman(shopman));
    }

    /**
     * 删除店铺信息
     */
    @PreAuthorize("@ss.hasPermi('shopman:shopman:remove')")
    @Log(title = "店铺信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{shopIds}")
    public AjaxResult remove(@PathVariable Long[] shopIds)
    {
        return toAjax(shopmanService.deleteShopmanByShopIds(shopIds));
    }
}
